package com.cskaoyan;

import com.cskaoyan.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * 创建日期: 2022/08/25 17:20
 *
 * @author ciggar
 */
public class ThirdJDBC {

    public static void main(String[] args) throws SQLException {

        // 获取连接
        Connection connection = JDBCUtils.getConnection();

        // 获取PreparedStatement
        PreparedStatement preparedStatement = connection.prepareStatement("insert into city values (?,?,?)");

        // 传参
        preparedStatement.setInt(1,9001);
        preparedStatement.setString(2,"理塘");
        preparedStatement.setInt(3,32);

        // 执行SQL
        int affectedRows = preparedStatement.executeUpdate();


        System.out.println("affectedRows:" + affectedRows);


        // 关闭资源
        JDBCUtils.close(null,preparedStatement,connection);


    }
}
